<?php
class RoleController extends FrontController
{
	public function loadAction()
	{
		$tbRole = new Table_Acl_Role();
		return $tbRole->toTreeStore();
	}
	
	public function addAction()
	{
		$tbRole = new Table_Acl_Role();
		
		$data = array(
			'parent_id' => $this->getRequest()->parentId,
			'name'		=> $this->getRequest()->name
		);
		
		$id = $tbRole->insert($data);
		return array('success' => true, 'id' => $id);
	}
	
	public function updateAction()
	{
		$tbRole = new Table_Acl_Role();
		
		$id = $this->getRequest()->id;
		$data = array('name'=> $this->getRequest()->name);
		
		$tbRole->updateById($id, $data);
		return array('success' => true);
	}
	
	public function delAction()
	{
		$tbRole = new Table_Acl_Role();
		$id = $this->getRequest()->id;
		
		$tbRole->deleteById($id);
		return array('success' => true);
	}
}